﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Model;
using BLL;

namespace Badminton
{
    public partial class FormLogin : Form
    {
        public FormLogin()
        {
            InitializeComponent();
        }
        public static string CurrentOperater;
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if(this.txtOperatername.Text.Trim()==null||this.txtOperaterPwd.Text.Trim()==null||this.txtOperaterIC.Text.Trim()==null)
            {
                MessageBox.Show(">>>>>>>>用户名、密码、证件号码不可以为空>>>>>>>>…………", "验证操作员……", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                //把当前的操作员的名字保存、以方便其他的窗口使用
                CurrentOperater=this.txtOperatername.Text.Trim();
                Model.Operator op = new Operator(CurrentOperater, this.txtOperaterPwd.Text.Trim(), this.txtOperaterIC.Text.Trim());
                if (BLL.BllOperater.CheckOperaterLogin(op))
                {
                    //MessageBox.Show("认证成功", "操作员的认证工作……", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Visible = false;
                    FormMain fm = new FormMain();
                    fm.Show();
                }
                else
                {
                    MessageBox.Show("用户名 或 密码、证件号码 错误", "验证操作员……", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

        }

        private void btnRegisterOperater_Click(object sender, EventArgs e)
        {
            RegisterOperatorForm rsf = new RegisterOperatorForm();
            this.Hide();
            rsf.Show();
        }

        private void FormLogin_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }


    }
}